﻿#ifndef _SCREENSCUTCHEONHANDLER_H
#define _SCREENSCUTCHEONHANDLER_H

#include "ga/guieventhandler.h"
#include "globecontrol/globecontrol.h"
#include "screenscutcheon.h"
#include "screenscutcheonevent.h"
#include "screenscutcheonmanager.h"


            class  CScreenScutcheonHandler : public EarthView::World::Spatial3D::Controls::CGUIEventHandler
            {
            public:
                /// <summary>
                /// 标牌输入交互控制器构造函数
                /// </summary>
                CScreenScutcheonHandler();

                /// <summary>
                /// 标牌输入交互控制器析构函数
                /// </summary>
                ~CScreenScutcheonHandler();

                /// <summary>
                ///单件模式获取CScreenScutcheonHandler对象
                /// </summary>
                static CScreenScutcheonHandler& getSingleton();

                /// <summary>
                ///单件模式获取CScreenScutcheonHandler指针
                /// </summary>
                static CScreenScutcheonHandler* getSingletonPtr();

                /// <summary>
                /// 响应处理消息
                /// </summary>
                /// <param name="guiEvent">消息事件</param>
                /// <returns>true为处理成功，false为处理失败</returns>
                ev_bool handleEvent(EarthView::World::Spatial::SystemUI::CGUIEvent* guiEvent);

                /// <summary>
                /// 响应帧事件消息
                /// </summary>
                /// <param name="guiEvent">消息事件</param>
                /// <returns>true为处理成功，false为处理失败</returns>
                ev_bool handleFrameEvent(EarthView::World::Spatial::SystemUI::CGUIEvent* guiEvent);

                /// <summary>
                /// 响应鼠标按下消息
                /// </summary>
                /// <param name="guiEvent">消息事件</param>
                /// <returns>true为处理成功，false为处理失败</returns>
                ev_bool handleMouseDownEvent(EarthView::World::Spatial::SystemUI::CGUIEvent* guiEvent);

                /// <summary>
                /// 响应鼠标移动消息
                /// </summary>
                /// <param name="guiEvent">消息事件</param>
                /// <returns>true为处理成功，false为处理失败</returns>
                ev_bool handleMouseMoveEvent(EarthView::World::Spatial::SystemUI::CGUIEvent* guiEvent);

                /// <summary>
                /// 响应滚动鼠标滑轮消息
                /// </summary>
                /// <param name="guiEvent">消息事件</param>
                /// <returns>true为处理成功，false为处理失败</returns>
                ev_bool handleMouseWheelEvent(EarthView::World::Spatial::SystemUI::CGUIEvent* guiEvent);

                /// <summary>
                /// 响应鼠标弹起消息
                /// </summary>
                /// <param name="guiEvent">消息事件</param>
                /// <returns>true为处理成功，false为处理失败</returns>
                ev_bool handleMouseUpEvent(EarthView::World::Spatial::SystemUI::CGUIEvent* guiEvent);

                /// <summary>
                /// 响应键盘按下消息
                /// </summary>
                /// <param name="guiEvent">消息事件</param>
                /// <returns>true为处理成功，false为处理失败</returns>
                ev_bool handleKeyDownEvent(EarthView::World::Spatial::SystemUI::CGUIEvent* guiEvent);

                /// <summary>
                /// 响应键盘弹起消息
                /// </summary>
                /// <param name="guiEvent">消息事件</param>
                /// <returns>true为处理成功，false为处理失败</returns>
                ev_bool handleKeyUpEvent(EarthView::World::Spatial::SystemUI::CGUIEvent* guiEvent);

                /// <summary>
                /// 设置地球控件
                /// </summary>
                /// <param name="ref_globeControl">地球控件</param>
                void setGlobeControl(EarthView::World::Spatial3D::Controls::CGlobeControl* ref_globeControl);

            protected:
                void computeSelected(ev_int32 x, ev_int32 y);

                void sendEvent(const CScreenScutcheonEvent::EVScreenScutcheonEventType& type, const int& x, const int& y);

            public:
                static ev_bool mIsHandlerAdded;

            protected:
				EarthView::World::Spatial3D::Controls::CGlobeControl* ref_mpGlobeControl;
                static CScreenScutcheonHandler* mpSingleton;
                CScutcheonMap mScutcheonMap;
                EarthView::World::Spatial::SystemUI::CGUIEvent* mpLastGuiEvent;
                EVString  mPanelElementName;
                EarthView::World::Spatial::Math::CVector2 mPos;
                //ev_int32 mSelectedIndex;
            };

#endif
